function cur=curvelet_mycandes(imSize,radial,angular)
%Implementation of the standart partition for the curvelet transformation
%
%author: Sebastian Schmelcher; version: 2012-04-24
identifier='mycandes';
map=get_indexStruct(identifier,imSize);

num_radial=length(map);


n=imSize(1);
m=imSize(2);

origin=get_origin([n,m]);

cur=zeros(imSize);


if(radial==0)
    cur(origin(1)-1:origin(1)+1,origin(2)-1:origin(2)+1)=[0.928241517645832,1,0.928241517645832;1,1,1;0.928241517645832,1,0.928241517645832];
    return;
end

if(radial>num_radial)
    return;
end

if(angular>map(radial))
    return;
end


scale=radial;
curvelet_dir=(angular-1)*2*pi/map(radial)+0.5*pi/map(radial);


[X,Y]=meshgrid(1-origin(1):n-origin(1),1-origin(2):m-origin(2));
[theta,rad]=cart2pol(X,Y);
rad=(2^(-scale)).*rad;
theta=(2^(ceil(scale/2)+1))*angle(exp(1i*(theta+curvelet_dir.*ones(imSize))))/pi;

if(radial==num_radial)
    cur=lastRadialWindow(rad).*angularWindow(theta); %no upper limit
else
    cur=radialWindow(rad).*angularWindow(theta);
end
   

% -------------------------------------------------------------------------
function x = lastRadialWindow(r)
%no upper limit
rSize=size(r);

x= (r>=(5/6));
x=x+cos((5*ones(rSize)-6*r)*(pi/2)).*(r>=(2/3)) .* (r<(5/6));

% -------------------------------------------------------------------------

function x = angularWindow(t)
t=abs(t);
tSize=size(t);
x=(t<=(1/3));
x=x+((t<=(2/3)) .* (t>1/3)).*cos(  (3*t-ones(tSize))*(pi/2) );



% -------------------------------------------------------------------------
function x = radialWindow(r)
rSize=size(r);

x=( (r>=(5/6)) .* (r<=(4/3)) );
x=x+cos((5*ones(rSize)-6*r)*(pi/2)).*(r>=(2/3)) .* (r<(5/6));
x=x+cos((3*r-4*ones(rSize))*(pi/2)).*(r>(4/3)) .* (r<=(5/3));


